﻿
namespace Patterns4Net.PatternEnforcer.Core.Patterns
{
    using System;
    using System.Linq;
    using Patterns4Net.Core.CecilExtensions;
    using Patterns4Net.Core.Patterns;

    [PatternCheckerExport(typeof(Prototype))]
    public class PrototypeChecker : FluentPatternChecker<Prototype>
    {
        public PrototypeChecker()
        {
            this.Type(pattern => pattern.TargetType)
                .Check(
                    type => type.Interfaces.Any(i => i.IsEqual(typeof(ICloneable))),
                    type => string.Format(ErrorMessages.PrototypeDoesNotImplementICloneable, type.Name));
        }
    }
}
